package com.ly.work;

import java.lang.Runnable;

public class Demo01 implements Runnable{

    public int i = 100;

    @Override
    public void run() {
        synchronized (Object.class) {
            while (true) {
                if (i >= 0) {
                    if (i % 2 == 0)
                        System.out.println(Thread.currentThread().getName() + "偶数" + i);
                    else
                        System.out.println(Thread.currentThread().getName() + "奇数" + i);

                    i--;
                }
            }
        }
    }
}

class DemoTest{
    public static void main(String[] args) {

        Demo01 demo01 = new Demo01();

        Thread tt = new Thread(demo01,"t3");
        Thread t2 = new Thread(demo01,"t2");

        tt.start();
        t2.start();
    }
}